package com.zxy.service;

import cn.hutool.core.date.DateUtil;
import com.zxy.dao.InventoryLogDao;
import com.zxy.dao.StockDao;
import com.zxy.model.Ordering;
import com.zxy.model.OrderingOk;

import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class StockService {

    @Autowired
    private StockDao stockDao;
    @Autowired
    private InventoryLogDao inventoryLogDao;
//    @Transactional
        @GlobalTransactional(name = "create_order")
    public int deduct(Integer productId,Integer qty){
        stockDao.deduct(productId, qty);
//        int a = 5/0;
        inventoryLogDao.log("商品id:"+productId+"扣除"+qty);
        return 1;
    }
}
